<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<link rel="stylesheet" href="/layui/css/layui.css">
<script src="/layui/layui.js"></script>
<style type="text/css">
	.layui-table-tips-main{display:none}
	.layui-table-tips-c{display:none}
</style>
</head>
<body class="layui-layout-body">
	<div class="layui-form"  style="margin-top: 20px;">
		<div class="layui-form toolbar">
			<div class="layui-form-item">
				<div class="layui-inline">
					<div class="layui-inline">
				      <div class="layui-input-inline">
				        <input type="text" class="layui-input" id="test6" placeholder="举报时间范围">
				      </div>
				    </div>
					<div class="layui-inline">
						<button id="authBtnSearch" class="layui-btn icon-btn layui-btn-normal"><i class="layui-icon"></i>搜索</button>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!--  数据data -->
	<div class="layui-row" style="padding: 0px 10px;" id="tablediv">
		<table id="table_data" lay-filter="test"  ></table>	
	</div>
	<!-- 表格操作列 -->
	<script type="text/html" id="authTableBar">
  		<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除评论</a>
  		<a class="layui-btn layui-btn-primary layui-btn-xs"  lay-event="ignore">忽略举报</a>
	</script>
	<script type="text/javascript">
		$(top.hangge());	
	</script>
	<script type="text/javascript">
	var tableIns ;
	var layer ;
	layui.use(['layer', 'form', 'table','element'], function(){
		  var table = layui.table;
		  var form = layui.form;
		  var element = layui.element;
		  layer=layui.layer;
		  
		  //加载层
		  var loadingIndex =layer.msg('数据加载中...', {
			   icon: 16
			  ,shade: 0.01
		  });  
		  
		  //第一个实例
		  var params = {};
		  tableIns = table.render({
		    elem: '#table_data',
		    url: '/admin/topic/findListData6',
		    page: true, //开启分页
		    where:params,
		    loading:true,
		    height: 'full-150',
		    cols: [
		    	[ //表头
		    	{field:'rid',title: '编号', hide: true}
               , {field: 'rsn', title: '知识编号',width:110}
               , {field: 'rdate', title: '举报时间',width:170}
               , {field: 'rmessage', title: '举报理由'}
               , {field: 'uname', title: '评论时间',width:170}
               , {field: 'rdisposemessage', title: '评论内容'}
		       , {templet: '#authTableBar', width: 180, align: 'center', title: '操作'}
		    	]
		   		],
		    done:function(res){
		    	layer.close(loadingIndex);
		    }
		  });
		  
		  //数据操作
		  table.on('tool(test)', function(obj){ //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
			  var data = obj.data //获得当前行数据
			    ,layEvent = obj.event; //获得 lay-event 对应的值
			    var rid=data.rid;
			    if(layEvent === 'del'){
			    	layer.confirm('确定要将该评论删除？', function(index){
				        obj.del(); //删除对应行（tr）的DOM结构
				        layer.close(index);
				        //向服务端发送删除指令
			    		del(rid);
			    	});
			    } else if(layEvent === 'ignore'){
			    	layer.confirm('确定要将该举报忽略？', function(index){
				        obj.del(); //删除对应行（tr）的DOM结构
				        layer.close(index);
				        //向服务端发送删除指令
			    		ignore(rid);
			    	});
			    } 
		});
	});
	function del(rid){
		var params={};
		params.id=rid;
		$.ajax( {
	         url : '/admin/topic/deleteComment', 
	         type : 'post',
	         data: params,
	         dataType : 'json',
	         success : function(data) {
	        	 if(data.code==0){
	        		 layer.msg(data.msg,{icon: 1});
	        		 Refresh();
	        	 }else{
	        		 layer.msg(data.msg,{icon: 2});
	        	 }
	         }
	     });
	}
	function ignore(rid){
		var params={};
		params.id=rid;
		$.ajax( {
	         url : '/admin/topic/ignoreComment', 
	         type : 'post',
	         data: params,
	         dataType : 'json',
	         success : function(data) {
	        	 if(data.code==0){
	        		 layer.msg(data.msg,{icon: 1});
	        		 Refresh();
	        	 }else{
	        		 layer.msg(data.msg,{icon: 2});
	        	 }
	         }
	     });
	}
	//搜索
	$("#authBtnSearch").click(function(){
		Refresh();
	});
	//刷新
	function Refresh(){
		var params = {};
		var authEdtSearch=$("#authEdtSearch").val();
		var kispopup=$("#kispopup").val();
		params.keywords=authEdtSearch;
		params.kispopup=kispopup;
		tableIns.reload({
			  where:params
			  ,page: {
				    curr: 1 //重新从第 1 页开始
				  }
		});	
	}
	</script>

<script type="text/javascript">
layui.use('laydate', function(){
	  var laydate = layui.laydate;
	  laydate.render({
	    elem: '#test6'
	    ,range: true
	  });
});
</script>
</body>
</html>